package mse.eai.jbpm.dailyDigestProcess;

import java.util.Map;

import org.jboss.logging.Logger;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

public class PrepareDigest implements ActionHandler {

	private static final Logger log = Logger.getLogger(PrepareDigest.class);

	@Override
	public void execute(ExecutionContext context) throws Exception {

		log.info("Executing ---------->");

		Map<Integer, String> mapOfEmails = (Map<Integer, String>) context
				.getVariable("MapOfEmails");
		
		//log.info("Got from context: " + "mapOfEmails  = " + mapOfEmails);
		
		Integer uid = (Integer) mapOfEmails.entrySet().iterator().next()
				.getKey();
		String email = mapOfEmails.get(uid);

		context.setVariable("uid", uid);
		context.setVariable("subject", "PhaseBook Daily Digest");
		context.setVariable("message", email);
		
	//	log.info("Set in context: " + "uid  = " + uid);
		//log.info("Set in context: " + "subject  = " + "PhaseBook Daily Digest");
		//log.info("Set in context: " + "message  = " + email);
		

		log.info("<--------------- Done");

		context.leaveNode();

	}

}
